#include <iostream>
#include "call_file.h"
#include <exception>
using namespace std;
using std::cout;
using std::endl;

void call_show(int call_var)
{
    int call_var1 = call_var;
    static double call_var2 = 100;
    char call_var3 = 'h';
    std::cout<<"Hello,World!"<<std::endl;
}

float call_division(int x, int y) {
    if( y == 0 ) {
        throw "Attempted to divide by zero!";
    }
    return (x/y);
}


int call_test_try_catch () {
    int i = 25;
    int j = 0;
    float k = 0;
    try {
        k = call_division(i, j);
    }catch (const char* e) {
        ;
    }
    return 0;
}

//递归，测试stepin 和调用栈查看
int call_factorial(int n)
{
    if(n<0)
        return(-1); /*Wrong value*/
    if(n==0)
        return(1);  /*Terminating condition*/
    else
    {
        return(n*call_factorial(n-1)); //打断点测试stepin/stepout
    }
}

class call_Student{
private:
    char *m_name;
    int m_age;
    float m_score;
public:
    //声明构造函数
    call_Student(char *name, int age, float score);
    //声明普通成员函数
    void call_student_show();
};

//定义构造函数
call_Student::call_Student(char *name, int age, float score){
    m_name = name;
    m_age = age;
    m_score = score;
}

//定义普通成员函数
void call_Student::call_student_show(){
    cout<<m_name<<"的年龄是"<<m_age<<"，成绩是"<<m_score<<endl;
}

int call_test_class(){
    //创建对象时向构造函数传参
    call_Student stu((char*)"小明", 15, 92.5); //断点，测试构造函数的stepin
    stu.call_student_show(); //断点，测试普通成员函数的stepin

    //创建对象时向构造函数传参
    call_Student *pstu = new call_Student((char*)"李华", 16, 96); //断点，测试构造函数的stepin
    pstu -> call_student_show(); //断点，测试普通成员函数的stepin
    return 0;
}